package com.gxa.web_admin.controller;

import cn.hutool.core.bean.BeanUtil;
import com.gxa.common.base.RespResult;
import com.gxa.web_admin.vo.SysUserVO;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/system/user")
public class SysUserController {

    @GetMapping("/info")
//    @RequiresPermissions("system:user:detail")
    public RespResult info(){
        System.out.println("======info=======");
        Subject subject = SecurityUtils.getSubject();
        SysUserVO sysUser = BeanUtil.copyProperties(subject.getPrincipal(), SysUserVO.class);
        return RespResult.success(sysUser);
    }

    @GetMapping("/add")
    public RespResult add(){
        return RespResult.success();
    }

    @GetMapping("/edit")
    public RespResult edit(){
        return RespResult.success();
    }


//权限的拦截测试
    @GetMapping("/detail")
    @RequiresPermissions(value = {"system:user:detail"})
    public RespResult detail(){
        System.out.println("=============");
        return RespResult.success();
    }

}
